package com.itheima.springboot.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.springboot.controller.dto.UserAddressDto;
import com.itheima.springboot.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<User> {
    // 一对多查询
    User getBookList(@Param("id") Long id);

    @Select("select count(id) count, address from user GROUP BY address")
    List<UserAddressDto> countAddress();
}
